﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using LPV_POS.Module;

namespace LPV_POS.mh_pos.mh_cauhinh
{
    public partial class mh_cauhinhtrangchu : DevExpress.XtraEditors.XtraForm
    {
        string[] arr_chucnang;
        DataTable tb;
        thuvien tv;
        string[] s;
        object[] o;
        private Int16 thongso = 0;
        private DataTable f_dschunang()
        {
            s = new string[] {"@flag","@choose" };
            o = new object[] {1,1 };
            tv = new thuvien();
            tb = tv.SP_SelectDataTable("sp_mhcauhinhchunang", s, o);
            return tb;
        }
        private DataTable f_dsfunction()
        {
            s = new string[] { "@flag", "@choose" };
            o = new object[] { 1, 3 };
            tv = new thuvien();
            tb = tv.SP_SelectDataTable("sp_mhcauhinhchunang", s, o);
            return tb;
        }
        private int f_clearfunction(string label_name)
        {
            int ketqua = -1;
            s = new string[] { "@flag", "@choose", "@TEN_LABEL" };
            o = new object[] { 2, 2, label_name };
            tv = new thuvien();
            ketqua = tv.SP_Update("sp_mhcauhinhchunang", s, o);
            return ketqua;
        }
        private void getdata_label(object sender, EventArgs e)
        {
            if (((LabelControl)sender).Tag != null && ((LabelControl)sender).Tag.ToString() != "" )
            {
                txt_chucnang.Text = ((LabelControl)sender).Tag.ToString().Substring(1, ((LabelControl)sender).Tag.ToString().Length - 1);
                if (txt_chucnang.Text == "1")
                    txt_chucnang.Text = "";
            }
            txt_ten.Text = ((LabelControl)sender).Text;
            txt_phongchu.Text = ((LabelControl)sender).Font.Name.ToString();
            txt_cochu.Text = ((LabelControl)sender).Font.Size.ToString();
            lbel_mauchu.BackColor = ((LabelControl)sender).ForeColor;
            lbel_maunen.BackColor = ((LabelControl)sender).BackColor;

        }

        private void f_clickdown(object sender, MouseEventArgs e)
        {
            ((LabelControl)sender).BorderStyle =DevExpress.XtraEditors.Controls.BorderStyles.Simple;
        }
        private void f_clickup(object sender, MouseEventArgs e)
        {
            ((LabelControl)sender).BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Style3D;
        }

        private void set_datalabel(LabelControl lbel_control,DataTable tb, int i)
        {
            byte font_r  = byte.Parse (tb.Rows[i]["FONT_COLOR_R"]+"");
            byte font_g = byte.Parse(tb.Rows[i]["FONT_COLOR_G"] + "");
            byte font_b = byte.Parse(tb.Rows[i]["FONT_COLOR_B"] + "");
            byte back_r = byte.Parse(tb.Rows[i]["BGROUND_COLOR_R"] + "");
            byte back_g = byte.Parse(tb.Rows[i]["BGROUND_COLOR_G"] + "");
            byte back_b = byte.Parse(tb.Rows[i]["BGROUND_COLOR_B"] + "");

            lbel_control.Tag = tb.Rows[i]["INDEX_FUNCTION"] + "" + tb.Rows[i]["FUNCTION_NAME"] + "";
            lbel_control.Text = tb.Rows[i]["FUNCTION_SHORT"] + "";
            lbel_control.Font = new Font(tb.Rows[i]["FONT"] + "", float.Parse(tb.Rows[i]["FONT_SIZE"] + ""));
            lbel_control.ForeColor = System.Drawing.Color.FromArgb(font_r,font_g,font_b);
            lbel_control.BackColor = System.Drawing.Color.FromArgb(back_r,back_g,back_b);
        }

       
        public mh_cauhinhtrangchu()
        {
            InitializeComponent();
        }

        

        private void bton_thoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void lbel_1_Click(object sender, EventArgs e)
        {
            thongso = 1;
            getdata_label(sender, e);

        }

        private void lbel_2_Click(object sender, EventArgs e)
        {
            thongso = 2;
            getdata_label(sender, e);
        }

        private void lbel_3_Click(object sender, EventArgs e)
        {
            thongso = 3;
            getdata_label(sender, e);
        }

        private void lbel_4_Click(object sender, EventArgs e)
        {
            thongso = 4;
            getdata_label(sender, e);
        }

        private void lbel_5_Click(object sender, EventArgs e)
        {
            thongso = 5;
            getdata_label(sender, e);

        }

        private void lbel_6_Click(object sender, EventArgs e)
        {
            thongso = 6;
            getdata_label(sender, e);
        }

        private void lbel_7_Click(object sender, EventArgs e)
        {
            thongso = 7;
            getdata_label(sender, e);
        }

        private void lbel_8_Click(object sender, EventArgs e)
        {
            thongso = 8;
            getdata_label(sender, e);
        }

        private void lbel_9_Click(object sender, EventArgs e)
        {
            thongso = 9;
            getdata_label(sender, e);
        }

        private void lbel_10_Click(object sender, EventArgs e)
        {
            thongso = 10;
            getdata_label(sender, e);
        }

        private void lbel_11_Click(object sender, EventArgs e)
        {
            thongso = 11;
            getdata_label(sender, e);
        }

        private void lbel_12_Click(object sender, EventArgs e)
        {
            thongso = 12;
            getdata_label(sender, e);
        }

        private void lbel_mauchu_Click(object sender, EventArgs e)
        {
            Variable.str_chu_nen = "chu";
            mh_color frm_color = new mh_color();
            frm_color.ShowDialog();
            if (Variable.int_close == -1)
                return;
            lbel_mauchu.BackColor = Variable.maunen;
            lbel_mauchu.ForeColor = Variable.maunen;
        }

        private void lbel_maunen_Click_1(object sender, EventArgs e)
        {
            Variable.str_chu_nen = "nen";
            mh_color frm_color = new mh_color();
            frm_color.ShowDialog();
            if (Variable.int_close == -1)
                return;
            lbel_maunen.BackColor = Variable.maunen;
        }

        private void lbel_maunen_BackColorChanged(object sender, EventArgs e)
        {
            switch (thongso)
            {
                case 1:
                    lbel_1.BackColor = lbel_maunen.BackColor;//Variable.maunen;
                    break;
                case 2:
                    lbel_2.BackColor = lbel_maunen.BackColor;//Variable.maunen;
                    break;
                case 3:
                    lbel_3.BackColor = lbel_maunen.BackColor;//Variable.maunen;
                    break;
                case 4:
                    lbel_4.BackColor = lbel_maunen.BackColor;//Variable.maunen;
                    break;
                case 5:
                    lbel_5.BackColor = lbel_maunen.BackColor;//Variable.maunen;
                    break;
                case 6:
                    lbel_6.BackColor = lbel_maunen.BackColor;//Variable.maunen;
                    break;
                case 7:
                    lbel_7.BackColor = lbel_maunen.BackColor;//Variable.maunen;
                    break;
                case 8:
                    lbel_8.BackColor = lbel_maunen.BackColor;//Variable.maunen;
                    break;
                case 9:
                    lbel_9.BackColor = lbel_maunen.BackColor;//Variable.maunen;
                    break;
                case 10:
                    lbel_10.BackColor = lbel_maunen.BackColor;//Variable.maunen;
                    break;
                case 11:
                    lbel_11.BackColor = lbel_maunen.BackColor;//Variable.maunen;
                    break;
                case 12:
                    lbel_12.BackColor = lbel_maunen.BackColor;//Variable.maunen;
                    break;   
          
        }
          //  Variable.maunen = System.Drawing.Color.Transparent;
          
        }
        private void lbel_mauchu_BackColorChanged(object sender, EventArgs e)
        {
            switch (thongso)
            {
                case 1:
                    lbel_1.ForeColor = lbel_mauchu.BackColor;
                    break;
                case 2:
                    lbel_2.ForeColor = lbel_mauchu.BackColor;
                    break;
                case 3:
                    lbel_3.ForeColor = lbel_mauchu.BackColor;
                    break;
                case 4:
                    lbel_4.ForeColor = lbel_mauchu.BackColor;
                    break;
                case 5:
                    lbel_5.ForeColor = lbel_mauchu.BackColor;
                    break;
                case 6:
                    lbel_6.ForeColor = lbel_mauchu.BackColor;
                    break;
                case 7:
                    lbel_7.ForeColor = lbel_mauchu.BackColor;
                    break;
                case 8:
                    lbel_8.ForeColor = lbel_mauchu.BackColor;
                    break;
                case 9:
                    lbel_9.ForeColor = lbel_mauchu.BackColor;
                    break;
                case 10:
                    lbel_10.ForeColor = lbel_mauchu.BackColor;
                    break;
                case 11:
                    lbel_11.ForeColor = lbel_mauchu.BackColor;
                    break;
                case 12:
                    lbel_12.ForeColor = lbel_mauchu.BackColor;
                    break;

            }
            //Variable.maunen = System.Drawing.Color.Transparent;
          
        }

        private void txt_ten_TextChanged(object sender, EventArgs e)
        {
            switch (thongso)
            {
                case 1:
                    lbel_1.Text = txt_ten.Text;
                    break;
                case 2:
                    lbel_2.Text = txt_ten.Text;
                    break;
                case 3:
                    lbel_3.Text = txt_ten.Text;
                    break;
                case 4:
                    lbel_4.Text = txt_ten.Text;
                    break;
                case 5:
                    lbel_5.Text = txt_ten.Text;
                    break;
                case 6:
                    lbel_6.Text = txt_ten.Text;
                    break;
                case 7:
                    lbel_7.Text = txt_ten.Text;
                    break;
                case 8:
                    lbel_8.Text = txt_ten.Text;
                    break;
                case 9:
                    lbel_9.Text = txt_ten.Text;
                    break;
                case 10:
                    lbel_10.Text = txt_ten.Text;
                    break;
                case 11:
                    lbel_11.Text = txt_ten.Text;
                    break;
                case 12:
                    lbel_12.Text = txt_ten.Text;
                    break;

            }
        }

       
        private void txt_cochu_TextChanged_1(object sender, EventArgs e)
        {
            cpublic change_int = new cpublic();
            switch (thongso)
            {
                case 1:
                    if (change_int.IsNumeric(txt_cochu.Text))
                        lbel_1.Font = new Font("Times New Roman", float.Parse(txt_cochu.Text));
                    else
                    {
                        return;
                    }
                    break;
                case 2:
                
                    if (change_int.IsNumeric(txt_cochu.Text))
                        lbel_2.Font = new Font("Times New Roman", float.Parse(txt_cochu.Text));
                    else
                    {
                        return;
                    }
                    break;
                case 3:
                    if (change_int.IsNumeric(txt_cochu.Text))
                        lbel_3.Font = new Font("Times New Roman", float.Parse(txt_cochu.Text));
                    else
                    {
                        return;
                    }
                    break;

                case 4:
                    if (change_int.IsNumeric(txt_cochu.Text))
                        lbel_4.Font = new Font("Times New Roman", float.Parse(txt_cochu.Text));
                    else
                    {
                        return;
                    }
                    break;

                case 5:
                    if (change_int.IsNumeric(txt_cochu.Text))
                        lbel_5.Font = new Font("Times New Roman", float.Parse(txt_cochu.Text));
                    else
                    {
                        return;
                    }
                    break;

                case 6:
                    if (change_int.IsNumeric(txt_cochu.Text))
                        lbel_6.Font = new Font("Times New Roman", float.Parse(txt_cochu.Text));
                    else
                    {
                        return;
                    }
                    break;

                case 7:
                    if (change_int.IsNumeric(txt_cochu.Text))
                        lbel_7.Font = new Font("Times New Roman", float.Parse(txt_cochu.Text));
                    else
                    {
                        return;
                    }
                    break;

                case 8:
                    if (change_int.IsNumeric(txt_cochu.Text))
                        lbel_8.Font = new Font("Times New Roman", float.Parse(txt_cochu.Text));
                    else
                    {
                        return;
                    }
                    break;

                case 9:
                    if (change_int.IsNumeric(txt_cochu.Text))
                        lbel_9.Font = new Font("Times New Roman", float.Parse(txt_cochu.Text));
                    else
                    {
                        return;
                    }
                    break;

                case 10:
                    if (change_int.IsNumeric(txt_cochu.Text))
                        lbel_10.Font = new Font("Times New Roman", float.Parse(txt_cochu.Text));
                    else
                    {
                        return;
                    }
                    break;

                case 11:
                    if (change_int.IsNumeric(txt_cochu.Text))
                        lbel_11.Font = new Font("Times New Roman", float.Parse(txt_cochu.Text));
                    else
                    {
                        return;
                    }
                    break;

                case 12:
                    if (change_int.IsNumeric(txt_cochu.Text))
                        lbel_12.Font = new Font("Times New Roman", float.Parse(txt_cochu.Text));
                    else
                    {
                        return;
                    }
                    break;
            }
        }

        private Size IsNumeri(string p)
        {
            throw new NotImplementedException();
        }

        private void lbel_1_MouseDown(object sender, MouseEventArgs e)
        {
            f_clickdown(sender,  e);
        }

        private void lbel_1_MouseUp(object sender, MouseEventArgs e)
        {
            f_clickup(sender, e);
        }

        private void bton_ten_Click(object sender, EventArgs e)
        {
            txt_ten.Text =  new cpublic().loadformchu_point(300, 200);
        }

        private void bton_cochu_Click(object sender, EventArgs e)
        {
            string cochu = new cpublic().loadformso_point(670, 270);
             if(Variable.int_close != -1)
                 txt_cochu.Text = cochu;
  
            Variable.int_close = 1;
        }

        private void txt_cochu_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!Char.IsDigit(e.KeyChar) && !Char.IsControl(e.KeyChar))
                e.Handled = true;

        }

        private void bton_phongchu_Click(object sender, EventArgs e)
        {

            mh_phongchu frm_phongchu = new mh_phongchu(txt_phongchu.Text,txt_cochu.Text, lbel_mauchu.BackColor);
            frm_phongchu.ShowDialog();
            if (Variable.int_close == -1)
                return;
            txt_cochu.Text =  frm_phongchu.lbel_view.Font.Size.ToString();
            lbel_mauchu.BackColor = frm_phongchu.lbel_mauchu.BackColor;
            txt_phongchu.Text = frm_phongchu.lbel_view.Font.FontFamily.Name ;
            Variable.int_close = 1; 
            //frm_phongchu.lbel_view
          
        }

        private void mh_cauhinhtrangchu_Load(object sender, EventArgs e)
        {
           
        
            luoi_chucnang.MainView = grid_chucnang;
            luoi_chucnang.DataSource = null;
            luoi_chucnang.DataSource = f_dsfunction();

            tb = f_dschunang();
            if (tb.Rows.Count > 0)
            {
                for (int i = tb.Rows.Count-1; i >=0; i--)
                {
                    switch (tb.Rows[i]["TEN_LABEL"] + "")
                        {
                        case "lbel_1":
                               
                                set_datalabel(lbel_1,tb,i);
                                break;
                        case "lbel_2":
                                set_datalabel(lbel_2, tb, i);
                             
                                break;
                        case "lbel_3":
                                set_datalabel(lbel_3, tb, i);
                             
                                break;
                        case "lbel_4":
                                set_datalabel(lbel_4, tb, i);
                            
                                break;
                        case "lbel_5":
                                set_datalabel(lbel_5, tb, i);
                              
                                break;
                        case "lbel_6":
                                set_datalabel(lbel_6, tb, i);
                                break;
                        case "lbel_7":
                                set_datalabel(lbel_7, tb, i);
                                break;
                        case "lbel_8":
                                set_datalabel(lbel_8, tb, i);
                                break;
                        case "lbel_9":
                                set_datalabel(lbel_9, tb, i);
                                break;
                        case "lbel_10":
                                set_datalabel(lbel_10, tb, i);
                                break;
                        case "lbel_11":
                                set_datalabel(lbel_11, tb, i);
                                break;
                        case "lbel_12":
                                set_datalabel(lbel_12, tb, i);
                                break;
                        }

                }
            }



          //  if(lbel_1.Tag.ToString().Length>0)
            //    txt_chucnang.Text = lbel_1.Tag.ToString().Substring(1, ((LabelControl)sender).Tag.ToString().Length - 1);
            txt_ten.Text = lbel_1.Text;
            txt_phongchu.Text = lbel_1.Font.FontFamily.Name;
            txt_cochu.Text = lbel_1.Font.Size.ToString();
            lbel_mauchu.BackColor = lbel_1.ForeColor;
            lbel_maunen.BackColor = lbel_1.BackColor;

        }

        private void grid_chucnang_Click(object sender, EventArgs e)
        {
            string index = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_index).ToString();
            foreach (LabelControl lbel in panel1.Controls)
            {
                if (lbel.Tag == null || lbel.Tag.ToString() == "")
                    lbel.Tag = "-1";
                     if (  lbel.Tag.ToString().Substring(0,1) == index)
                        {
                            Mod_messagebox mess = new Mod_messagebox();
                            mess.messagebox_pos("Thông báo", "Chức năng này đã sử dụng", loaithongbao.thongtin.GetHashCode());
                            return;
                        }
            }

            switch (thongso)
            {
                case 1:
                    lbel_1.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    lbel_1.Tag = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_index).ToString()  +
                                        grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_tenchucnang).ToString();
                    txt_chucnang.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    break;
                case 2:
                    lbel_2.Tag = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_index).ToString() +
                        grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_tenchucnang).ToString() ;
                    lbel_2.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    txt_chucnang.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    break;
                case 3:
                    
                    lbel_3.Tag = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_index).ToString() +
                                        grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_tenchucnang).ToString();
                    lbel_3.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    txt_chucnang.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    break;
                case 4:
                    
                    lbel_4.Tag = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_index).ToString() +
                                        grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_tenchucnang).ToString();
                    lbel_4.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    txt_chucnang.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    break;
                case 5:
                    
                    lbel_5.Tag = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_index).ToString() +
                                        grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_tenchucnang).ToString();
                    lbel_5.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    txt_chucnang.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    break;
                case 6:
                   
                    lbel_6.Tag = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_index).ToString() +
                                        grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_tenchucnang).ToString();
                    lbel_6.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    txt_chucnang.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    break;
                case 7:
                    
                    lbel_7.Tag = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_index).ToString() +
                                        grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_tenchucnang).ToString();
                    lbel_7.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    txt_chucnang.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    break;
                case 8:
                    
                    lbel_8.Tag = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_index).ToString() +
                                        grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_tenchucnang).ToString();
                    lbel_8.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    txt_chucnang.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    break;
                case 9:
                    
                    lbel_9.Tag = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_index).ToString() +
                                        grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_tenchucnang).ToString();
                    lbel_9.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    txt_chucnang.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    break;
                case 10:
                    
                    lbel_10.Tag = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_index).ToString() +
                                            grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_tenchucnang).ToString();
                    lbel_10.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    txt_chucnang.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    break;
                case 11:
                    
                    lbel_11.Tag = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_index).ToString() +
                                            grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_tenchucnang).ToString();
                    lbel_11.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    txt_chucnang.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    break;
                case 12:
                    
                    lbel_12.Tag = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_index).ToString() +
                                          grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_tenchucnang).ToString();
                    lbel_12.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    txt_chucnang.Text = grid_chucnang.GetRowCellValue(grid_chucnang.FocusedRowHandle, col_chucnang).ToString();
                    break;
            }
          
        }

        private void lbel_1_TextChanged(object sender, EventArgs e)
        {
            thongso = 1;
            getdata_label(sender, e);
        }

        private void lbel_2_TextChanged(object sender, EventArgs e)
        {
            thongso = 2;
            getdata_label(sender, e);
        }

        private void lbel_3_TextChanged(object sender, EventArgs e)
        {
            thongso = 3;
            getdata_label(sender, e);
        }

        private void lbel_4_TextChanged(object sender, EventArgs e)
        {
            thongso = 4;
            getdata_label(sender, e);
        }

        private void lbel_5_TextChanged(object sender, EventArgs e)
        {
            thongso = 5;
            getdata_label(sender, e);
        }

        private void lbel_6_TextChanged(object sender, EventArgs e)
        {
            thongso = 6;
            getdata_label(sender, e);
        }

        private void lbel_7_TextChanged(object sender, EventArgs e)
        {
            thongso = 7;
            getdata_label(sender, e);
        }

        private void lbel_8_TextChanged(object sender, EventArgs e)
        {
            thongso = 8;
            getdata_label(sender, e);
        }

        private void lbel_9_TextChanged(object sender, EventArgs e)
        {
            thongso = 9;
            getdata_label(sender, e);
        }

        private void lbel_10_TextChanged(object sender, EventArgs e)
        {
            thongso = 10;
            getdata_label(sender, e);
        }

        private void lbel_11_TextChanged(object sender, EventArgs e)
        {
            thongso = 11;
            getdata_label(sender, e);
        }

        private void lbel_12_TextChanged(object sender, EventArgs e)
        {
            thongso = 12;
            getdata_label(sender, e);
        }

        private void txt_phongchu_TextChanged(object sender, EventArgs e)
        {
            float cochu = float.Parse( txt_cochu.Text == "" ? "1" : txt_cochu.Text);
            switch (thongso)
            {
                case 1:
                    lbel_1.Font = new Font(txt_phongchu.Text, cochu);
                    break;
                case 2:
                    lbel_2.Font = new Font(txt_phongchu.Text, cochu);
                    break;
                case 3:
                    lbel_3.Font = new Font(txt_phongchu.Text, cochu);
                    break;
                case 4:
                    lbel_4.Font = new Font(txt_phongchu.Text, cochu);
                    break;
                case 5:
                    lbel_5.Font = new Font(txt_phongchu.Text, cochu);
                    break;
                case 6:
                    lbel_6.Font = new Font(txt_phongchu.Text, cochu);
                    break;
                case 7:
                    lbel_7.Font = new Font(txt_phongchu.Text, cochu);
                    break;
                case 8:
                    lbel_8.Font = new Font(txt_phongchu.Text, cochu);
                    break;
                case 9:
                    lbel_9.Font = new Font(txt_phongchu.Text, cochu);
                    break;
                case 10:
                    lbel_10.Font = new Font(txt_phongchu.Text, cochu);
                    break;
                case 11:
                    lbel_11.Font = new Font(txt_phongchu.Text, cochu);
                    break;
                case 12:
                    lbel_12.Font = new Font(txt_phongchu.Text, cochu);
                    break;

            }
        }

        private void bton_luu_Click(object sender, EventArgs e)
        {
            try
            {
               
                // luu thay đổi;
                tv = new thuvien();
                foreach (LabelControl lbel in panel1.Controls)
                {
                    string function_name ="";
                    string index = "";
                    if (lbel.Tag.ToString().Length > 0)
                    {
                        function_name = lbel.Tag.ToString().Substring(1, lbel.Tag.ToString().Length - 1);
                        index = lbel.Tag.ToString().Substring(0, 1);
                        if (function_name == "1")
                        {
                            function_name = "";
                            index = "";
                        }

                    }
                    if (check_khoiphuc.Checked == true)
                        lbel.Font = new Font("Times New Roman", 23);

                    s = new string[] { "@flag", "@choose", "@INDEX_FUNCTION","@FUNCTION_NAME","@FUNCTION_SHORT", "@FONT", "@FONT_SIZE", 
                                            "@FONT_COLOR_R","@FONT_COLOR_G","@FONT_COLOR_B", 
                                            "@BGROUND_COLOR_R","@BGROUND_COLOR_G","@BGROUND_COLOR_B", "@TEN_LABEL" };
                    o = new object[] { 2, 1, index,function_name,lbel.Text, lbel.Font.FontFamily.Name, lbel.Font.Size.ToString(), 
                                                lbel.ForeColor.R, lbel.ForeColor.G, lbel.ForeColor.B,  
                                                lbel.BackColor.R, lbel.BackColor.G, lbel.BackColor.B, lbel.Name };
                    tv.SP_Update("sp_mhcauhinhchunang", s, o);

                }
                this.Close();
            }
            catch (Exception)
            {

                Mod_messagebox mess = new Mod_messagebox();
                mess.messagebox_pos("Thông báo", "Cập nhật chưa thành công", loaithongbao.thongtin.GetHashCode());
            }
        }

        private void bton_xoa_Click(object sender, EventArgs e)
        {
         
            
            switch (thongso)
            {
                case 1:
                    lbel_1.Text = "";
                    lbel_1.Tag = "";
                   
                    break;
                case 2:
                    Mod_messagebox mess = new Mod_messagebox();
                    mess.messagebox_pos("Thông báo", "Không thể xóa cài đặt", loaithongbao.thongtin.GetHashCode());
                   //lbel_2.Text = "";
                    //lbel_2.Tag = "";    
                    break;

                case 3:
                    lbel_3.Text = "";
                    lbel_3.Tag = "";
                   
                    break;
                case 4:
                    lbel_4.Text = "";
                    lbel_4.Tag = "";
                    
                    break;
                case 5:
                    lbel_5.Text = "";
                    lbel_5.Tag = "";
                
                    break;
                case 6:
                    lbel_6.Text = "";
                    lbel_6.Tag = "";
                    
                    break;
                case 7:
                    lbel_7.Text = "";
                    lbel_7.Tag = "";
                
                    break;
                case 8:
                    lbel_8.Text = "";
                    lbel_8.Tag = "";
                  
                    break;
                case 9:
                    lbel_9.Text = "";
                    lbel_9.Tag = "";
                  
                    break;
                case 10:
                    lbel_10.Text = "";
                    lbel_10.Tag = "";
                
                    break;
                case 11:
                    lbel_11.Text = "";
                    lbel_11.Tag = "";
                 
                    break;
                case 12:
                    lbel_12.Text = "";
                    lbel_12.Tag = "";
                  
                    break;
            }

        }

        private void check_khoiphuc_CheckedChanged(object sender, EventArgs e)
        {
            if (check_khoiphuc.Checked == true)
            {
                
                lbel_1.BackColor = System.Drawing.Color.FromArgb(254, 255, 153);
                lbel_1.ForeColor = System.Drawing.Color.Blue;
                lbel_1.Text = "Bán hàng";
                lbel_1.Tag = "aBán hàng";
            


                lbel_2.BackColor = System.Drawing.Color.FromArgb(2, 88, 171);
                lbel_2.ForeColor = System.Drawing.Color.White;
                lbel_2.Text = "Cài đặt";
                lbel_2.Tag = "bCài đặt";
            

                lbel_3.BackColor = System.Drawing.Color.FromArgb(254, 255, 153);
                lbel_3.ForeColor = System.Drawing.Color.Green;
                lbel_3.Text = "Báo cáo";
                lbel_3.Tag = "cBáo cáo";


                lbel_4.BackColor = System.Drawing.Color.FromArgb(152, 203, 0);
                lbel_4.ForeColor = System.Drawing.Color.Black;
                lbel_4.Text = "Vào ca";
                lbel_4.Tag = "dVào ca";
              

                lbel_5.BackColor = System.Drawing.Color.Silver;
                lbel_5.ForeColor = System.Drawing.Color.Maroon;
                lbel_5.Text = "Quản lý kho";
                lbel_5.Tag = "eQuản lý kho";
              
                lbel_6.BackColor = System.Drawing.Color.FromArgb(51, 203, 204);
                lbel_6.ForeColor = System.Drawing.Color.Red;
                lbel_6.Text = "Ra ca";
                lbel_6.Tag = "fRa ca";
               
                lbel_7.BackColor = System.Drawing.Color.FromArgb(0, 0, 254);
                lbel_7.ForeColor = System.Drawing.Color.White;
                lbel_7.Text = "Danh sách trả lại";
                lbel_7.Tag= "gDanh sách trả lại";
             
                lbel_8.BackColor = System.Drawing.Color.FromArgb(236, 233, 216);
                lbel_8.ForeColor = System.Drawing.Color.Black;
                lbel_8.Text = "Thay đổi ngày làm";
                lbel_8.Tag = "hThay đổi ngày làm";
               
                lbel_9.BackColor = System.Drawing.Color.FromArgb(254, 255, 153);
                lbel_9.ForeColor = System.Drawing.Color.Blue;
                lbel_9.Text = "Thu chi";
                lbel_9.Tag = "kThu chi";
               

                lbel_10.BackColor = System.Drawing.Color.FromArgb(51, 203, 204);
                lbel_10.ForeColor = System.Drawing.Color.Black;
                lbel_10.Text = "";
                lbel_10.Tag = "";
             

                lbel_11.BackColor = System.Drawing.Color.White;
                lbel_11.ForeColor = System.Drawing.Color.Black;
                lbel_11.Text = "";
                lbel_11.Tag = "";
              

                lbel_12.BackColor = System.Drawing.Color.Red;
                lbel_12.ForeColor = System.Drawing.Color.Black;
                lbel_12.Text = "Thoát";
                lbel_12.Tag = "lThoát";
              

            }
        }

    
      
    }
}